package com.jl.jlapp.adapter;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jl.jlapp.R;

import java.util.List;
import java.util.Map;

public class BrandOrderByRecyclerAdapter
        extends Adapter<BrandOrderByRecyclerAdapter.ViewHolder>
        implements OnClickListener {
    private RelativeLayout brandBackground;
    private ImageView brandIsCheckImg;
    private TextView brandNameText;
    List<Map<String, Object>> checkedBrandMsgList;
    private List<String> data;
    private LayoutInflater inflater;
    private RecyclerView mRecyclerView;
    private OnItemClickListener onItemClickListener;

    public BrandOrderByRecyclerAdapter(Context paramContext, List<String> paramList) {
        this.data = paramList;
        this.inflater = LayoutInflater.from(paramContext);
    }

    public int getItemCount() {
        if (this.data != null) {
            return this.data.size();
        }
        return 0;
    }

    public void onAttachedToRecyclerView(RecyclerView paramRecyclerView) {
        super.onAttachedToRecyclerView(paramRecyclerView);
        this.mRecyclerView = paramRecyclerView;
    }

    @Override
    public void onBindViewHolder(ViewHolder paramViewHolder, int paramInt) {
        paramViewHolder.name.setText((CharSequence) this.data.get(paramInt));
        paramViewHolder.brandBackground.setBackgroundResource(R.drawable.goods_check_button_xs);
        paramViewHolder.brandIsChecked.setVisibility(View.GONE);
        paramViewHolder.name.setTextColor(Color.parseColor("#333333"));
        if (this.checkedBrandMsgList != null) {
            int i = 0;
            while (i < this.checkedBrandMsgList.size()) {
                if (this.data.get(paramInt) == (String) ((Map) this.checkedBrandMsgList.get(i)).get("brandName")) {
                    paramViewHolder.brandBackground.setBackgroundResource(R.drawable.goods_check_button_xs_checked);
                    paramViewHolder.brandIsChecked.setVisibility(View.VISIBLE);
                    paramViewHolder.name.setTextColor(Color.parseColor("#60b746"));
                }
                i += 1;
            }
        }
    }

    public void onClick(View paramView) {
        int j = this.mRecyclerView.getChildAdapterPosition(paramView);
        this.brandBackground = ((RelativeLayout) paramView.findViewById(R.id.check_brand_relativelayout));
        this.brandIsCheckImg = ((ImageView) paramView.findViewById(R.id.brand_checkmark));
        this.brandNameText = ((TextView) paramView.findViewById(R.id.brand_name));
        if (this.brandIsCheckImg.getVisibility() == View.VISIBLE) {
            this.brandBackground.setBackgroundResource(R.drawable.goods_check_button_xs);
            this.brandIsCheckImg.setVisibility(View.GONE);
            this.brandNameText.setTextColor(paramView.getResources().getColor(R.color.basic_wheelview_color));
        }
        for (int i = 0; ; i = 1) {
            if (this.onItemClickListener != null) {
                this.onItemClickListener.onItemClick(j, i, (String) this.data.get(j));
            }
            this.brandBackground.setBackgroundResource(R.drawable.goods_check_button_xs_checked);
            this.brandIsCheckImg.setVisibility(View.VISIBLE);
            this.brandNameText.setTextColor(paramView.getResources().getColor(R.color.checkGreenColor));
            return;
        }
    }

    public ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt) {
        paramViewGroup = (ViewGroup) this.inflater.inflate(R.layout.shop_list_brand_search_item, paramViewGroup, false);
        paramViewGroup.setOnClickListener(this);
        return new ViewHolder(paramViewGroup);
    }



    public void setCheckedBrandMsgList(List<Map<String, Object>> paramList) {
        this.checkedBrandMsgList = paramList;
    }

    public void setOnItemClickListener(OnItemClickListener paramOnItemClickListener) {
        this.onItemClickListener = paramOnItemClickListener;
    }

    public static abstract interface OnItemClickListener {
        public abstract void onItemClick(int paramInt1, int paramInt2, String paramString);
    }

    public static class ViewHolder
            extends RecyclerView.ViewHolder {
        RelativeLayout brandBackground;
        ImageView brandIsChecked;
        TextView name;

        public ViewHolder(View paramView) {
            super(paramView);
            this.name = ((TextView) paramView.findViewById(R.id.brand_name));
            this.brandBackground = ((RelativeLayout) paramView.findViewById(R.id.check_brand_relativelayout));
            this.brandIsChecked = ((ImageView) paramView.findViewById(R.id.brand_checkmark));
        }
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/adapter/BrandOrderByRecyclerAdapter.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */